package com.digital.welcome.controller;


import com.digital.welcome.annotation.OperationLog;
import com.digital.welcome.entity.OperateLog;
import com.digital.welcome.entity.PageRequest;
import com.digital.welcome.service.OperateLogService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 韩
 */
@RestController
@RequestMapping("/operate-log")
public class OperateLogController {

    @Autowired
    private OperateLogService operateLogService;

    @OperationLog()
    @ApiOperation("分页查询操作日志")
    @RequiresPermissions("log")
    @RequestMapping(value = "/find-page", method = RequestMethod.POST)
    public Object findPage(@RequestBody PageRequest pageRequest) {
        return operateLogService.findPage(pageRequest);
    }

    @OperationLog()
    @ApiOperation("操作日志删除")
    @RequiresPermissions("log")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public String delete(OperateLog operateLog) {
        return operateLogService.delete(operateLog);
    }

    @ApiOperation("操作日志查询")
    @RequiresPermissions("log")
    @RequestMapping(value = "/select", method = RequestMethod.POST)
    public String selectLog(@RequestBody PageRequest pageRequest) {
        return operateLogService.selectLog(pageRequest);
    }
}
